define(function(require, exports, module) {

  var Backbone = require('backbone');
  var $ = require('jquery');
  var _ = require('underscore');
  var jsonview = require('jsonview');

  var user = {
    "errCode": 200,
    "message": null,
    "data": {
      "userId": "e0a67e986a594a61b3d1e523a0a39c77",
      "realname": "demo",
      "username": "demo",
      "email": "demo@uyunsoft.cn",
      "mobile": "13172944690",
      "passwd": null,
      "description": null,
      "tenantId": "e0a67e986a594a61b3d1e523a0a39c77",
      "tenantName": "",
      "addTime": 1464312392000,
      "inviteCode": null,
      "qq": "000",
      "weixin": "oooo",
      "site": "https://www.oooo.cn",
      "root": true,
      "products": [{
        "productId": "0278ec244cab4a798b53b96bd01015ea",
        "productNum": "1005",
        "productName": "Automation",
        "description": null,
        "productUrl": "http://automation.uyuntest.cn",
        "enabled": 1,
        "orderby": 6,
        "addTime": 1464662443000,
        "role": 0
      }, {
        "productId": "057c5cf61519403dab3ee2e9e5bc1412",
        "productNum": "1002",
        "productName": "WEB",
        "description": null,
        "productUrl": "http://web.uyuntest.cn",
        "enabled": 1,
        "orderby": 1,
        "addTime": 1464662443000,
        "role": 0
      }, {
        "productId": "085377a2ffd04f048c4728111ade9872",
        "productNum": "1003",
        "productName": "Mobile",
        "description": null,
        "productUrl": "http://mobile.uyuntest.cn",
        "enabled": 1,
        "orderby": 3,
        "addTime": 1464662443000,
        "role": 0
      }, {
        "productId": "0eaa0d236ce7498189e18b9d21de5243",
        "productNum": "1006",
        "productName": "APM",
        "description": null,
        "productUrl": "http://apm.uyuntest.cn/",
        "enabled": 1,
        "orderby": 4,
        "addTime": 1464662443000,
        "role": 0
      }, {
        "productId": "3d5985a348654068a22c6367db36b1aa",
        "productNum": "1001",
        "productName": "Monitor",
        "description": "??????",
        "productUrl": "http://monitor.uyuntest.cn",
        "enabled": 1,
        "orderby": 1,
        "addTime": 1464662443000,
        "role": 0
      }, {
        "productId": "56e565194e86425f883db27299b50702",
        "productNum": "1007",
        "productName": "Show",
        "description": "运维可视化",
        "productUrl": "https://show.uyuntest.cn/",
        "enabled": 1,
        "orderby": 1,
        "addTime": 1465814900000,
        "role": 1
      }, {
        "productId": "b2437c46e76a4e75924c59dc267fe202",
        "productNum": "1004",
        "productName": "CMDB",
        "description": "运维管理的元数据，驱动您的运维场景",
        "productUrl": "http://cmdb.uyuntest.cn/",
        "enabled": 1,
        "orderby": 5,
        "addTime": 1464662443000,
        "role": 0
      }, {
        "productId": "ee47b1987fc94de785783d40ac2e2b45",
        "productNum": "1011",
        "productName": "WEB1",
        "description": null,
        "productUrl": "http://browser1.uyuntest.cn",
        "enabled": 1,
        "orderby": 8,
        "addTime": 1465901620000,
        "role": 0
      }, {
        "productId": "ee47b1987fc94de232283d40ac2e2b45",
        "productNum": "1008",
        "productName": "ITSM",
        "description": "流程",
        "productUrl": "http://itsm.uyuntest.cn",
        "enabled": 1,
        "orderby": 8,
        "addTime": 1465901620000,
        "role": 1
      }]
    }
  }


  function main() {
    var $app = $('<div id="app">');
    $('#main').html($app);

    var arr = [];

    for (var i = 0; i < 10; i++) {
      arr[i] = init()
      arr[i].a.errCode = i
    }

    for (var i = 0; i < 10; i++) {
      arr[i].destroy()
      arr[i] = null;
    }
  }

  function init() {
    let a = new clazz()

    setTimeout(function() {
      console.log(a.a.errCode)
    }, 3000)
    return a;
  }

  function clazz() {
    this.a = _.clone(user, true);
  }

  clazz.prototype.destroy = function() {
    this.a = null
  }

  return main;
})
